package de.openlaboratory.elib.controller;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import de.openlaboratory.elib.core.LogManager;
import de.openlaboratory.elib.model.library.Author;

public class AuthorDAO extends GenericDAOHibernate<Author, Long>
{

	public AuthorDAO()
	{
		super(Author.class);
	}
	
	public List<Author> findAll()
	{
		List<Author> authors = null;

		try
		{
			authors = (List<Author>) super.findAll(new Author());
		}
		catch (Exception p)
		{
			LogManager.logMessage(p.getMessage());
		}
		return authors;
	}

	public Set<Author> findByIds(Long[] authorIDs)
	{
		Set<Author> authors = new HashSet<Author>();
		
		if(authorIDs != null)
		{
			for(Long id: authorIDs)
			{
				authors.add((Author) super.find(new Author(), id));
			}
		}

		return authors;
	}
}